# -*- coding = utf-8 -*-
# @Time : 2021/11/17 17:14
# @Author : chenxingjia
# @File : testUrllib.py


import urllib.request
import urllib.parse          # 解析器


# 获取一个get请求
# response = urllib.request.urlopen("http://www.baidu.com")
# print(response)
# print(response.read().decode('UTF-8'))                        # 对获取的网页进行UTF-8解码

# 获取一个post请求
data = bytes(urllib.parse.urlencode({"hello":"world"}), encodings = 'UTF-8')
response = urllib.request.urlopen("http://httpbin.org/post")
print(response.read())